<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>确认信息-去保养-氦修驿站旗下品牌</title>
    <meta name="keywords" content="汽车保养,汽车配件,汽车维修,养车无忧,养车,4S店品质,氦修驿站,丰田保养" />
    <meta name="description" content="100%正品配件,4S店一半价格,先行赔付,闪电送达!线上购买配件,线下提供安装.上万用户的最佳选择!去掉中间环节,直接从源头采购配件!" />
	<link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/base.css">
    <link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/baoyang.css">
</head>
<body>

    <include file="Public:header" />

    <div id="wrap">
        <div class="title">
            <h2>预约保养</h2>
            <p class="step">
                <em>1、选择车型</em><i>&#xe606;</i>
                <em>2、选择服务</em><i>&#xe606;</i>
                <em>3、选择维修厂</em><i>&#xe606;</i>
                <em class="current">4、确认信息</em>
            </p>
        </div>
        <div class="cart">
            <table>
                <tr class="bg">
                    <td>
                        {$goods[0]['name']} * {$goods[0]['count']} <span>￥{$goods[0]['price']*$goods[0]['count']}</span><br />
                        {$goods[1]['name']} * {$goods[1]['count']} <span>￥{$goods[1]['price']}</span><br />
                    </td>
                    <td>
                        {$company['name']}<br />
                        {$company['address']}<br />
                    </td>
                    <td>{$auto['brand_name']} {$auto['model_name']} {$auto['model_pl']} {$auto['model_year']}</td>
                    <td>
                        <span class="fs16" id="J_price">￥{$goods[0]['price']*$goods[0]['count']+$goods[1]['price']}</span>
                    </td>
                </tr>
                <notempty name="goods[2]">
                <tr class="info">
                    <td align="right">附加项：</td>
                    <td colspan="2" align="left">

                        <eq name="goods[0]['id']" value="$goods[2]['id']">
                            {$goods[2]['name']} {$goods[2]['weight']}*{$goods[2]['count']}
                            <span>￥{$goods[2]['price']*($goods[2]['count'])}</span>
                        <else />

                        <if condition="($goods[0]['count']-1) neq 0">
                            {$goods[0]['name']} {$goods[0]['weight']}*{$goods[0]['count']-1}
                            <span>￥{$goods[0]['price']*($goods[0]['count']-1)}</span>
                            <br />
                        </if>
                        <if condition="$goods[2]['count'] neq 0">
                            {$goods[2]['name']} {$goods[2]['weight']}*{$auto['capacity']%4}
                            <span>￥{$goods[2]['price']*$goods[2]['count']}</span>
                            <br />
                        </if>
                        </eq>
                        <p class="J_coupon"></p>
                    </td>
                    <td></td>
                </tr>
                </notempty>
            </table>

            <div class="total">
                总计：
                <span>￥

<php>echo $goods[2]['price']*$goods[2]['count']+$goods[0]['price']*$goods[0]['count']+$goods[1]['price'];</php>
                </span>
            </div>
            <form action="{:U('step5')}" method="post" id="J_myForm">
                <div class="coupon">
                    <p>使用优惠券：</p>
                    <input type="text" value='' id="J_coupon" name="coupon" /><a href="javascript:void(0)" id="J_useCoupon">使用</a>
                </div>
                
                <div class="otherData">
                    <p>您的预约信息</p>
                    <ul>
                        <li>您的姓名：<input type="text" name="realname" value="{$_SESSION['user']['realname']}" placeholder="请输入您的姓名"  /></li>
                        <li>手机号码：<input type="text" name="phone" value="{$_SESSION['user']['username']}" placeholder="您的手机号码"  /></li>
                    </ul>
                </div>
                <div class="btn clearfix">
                    <input type="hidden" name="source" value="3">
                    <a href="javascript:void(0)" class="btnSubmit" id="J_btnSubmit">立即支付</a>
                    <a href="javascript:void(0)" onclick="window.history.go(-1)" class="back">返回</a>
                </div>
            </form>
        </div>
        
    </div>


    <include file="Public:footer" />
    <include file="Public:loginReg" />
    <script type="text/javascript" src="{:C('WEB_URL')}Public/js/baseFn.js"></script>
    <script type="text/javascript" src="{:C('WEB_URL')}Public/js/My97DatePicker/WdatePicker.js"></script>

    <script>
    $(".companyList").children("ul").on("click",function(e){
        var element=e.target.tagName==="LI"?$(e.target):$(e.target).parents("li");
        element.addClass("current").siblings("li").removeClass("current");
        setCookie("wx_id",element.attr("data-id"));
    })

    $("#J_btnSubmit").on("click",function(){
        var realname=$("input[name='realname']").val(),
            phone=$("input[name='phone']").val();
        if(realname==""){
            alert("请输入您的姓名");
            $("input[name='realname']").focus();
            return false;
        }else if(!/^(13|15|18|14|17)[0-9]{9}$/.test(phone)){
            alert("请输入正确的手机号码");
            $("input[name='phone']").focus();
            return false;
        }
        $("#J_myForm").submit();
    })


    $("#J_useCoupon").on("click",function(){
        var code=$("#J_coupon").val();
        if(!/\d{16}/.test(code)){
           alert("请输入正确的优惠码");
           return false;
        }
        $.ajax({
            url:"/baoyang/coupon/",
            type:"post",
            data:{"code":code},
            dataType:"json",
            success:function(res){
                if(res.status==1){
                    printCoupon(res.data);
                }else{
                    alert(res.info);
                }
            }
        })
    })

    function printCoupon(data){
        if($(".total > span").html().replace(/\D/g,"")<299){
            alert("当前的套餐不在该券的使用范围内");
            return false;
        };

        //$("#J_coupon").prop("disabled","disabled");
        $(".J_coupon").html("去保养优惠券满299减<span style='color:#78B930'>￥10</span>");
        $(".total").html("<span>￥"+($(".total").html().replace(/\D/g,"")-10)+"</span>");
    }


    </script>

</body>
</html>